import request from '@/utils/request'

const api_name = '/acl/user'

export default {
  // 新增管理用户
  save(user) {
    return request({
      url: `${api_name}`,
      method: 'post',
      data: user
    })
  },
  // 获取管理用户分页列表
  getPageList(userQuery) {
    return request({
      url: `${api_name}/list`,
      method: 'post',
      data: userQuery
    })
  },
  // 根据Id查询用户
  getById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'get'
    })
  },
  // 修改用户信息
  updateById(user) {
    return request({
      url: `${api_name}`,
      method: 'put',
      data: user
    })
  },
  // 根据用户获取角色数据
  getAssign(userId) {
    return request({
      url: `${api_name}/assign/${userId}`,
      method: 'get'
    })
  },
  // 根据用户分配角色
  saveAssign(userId, roleId) {
    return request({
      url: `${api_name}/assign`,
      method: 'post',
      params: { userId, roleId }
    })
  },
  // 根据ID删除用户
  removeById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'delete'
    })
  },
  // 批量删除用户
  removeRows(idList) {
    return request({
      url: `${api_name}/list`,
      method: 'delete',
      data: idList
    })
  }
}
